package isanfeng.tuxiaoer.pattern.creational.Asimplefactory;

/**
 * @author 李红辉
 * @version 1.0
 * @date 2019/8/29 17:05
 */
public class VideoFactory {
//    public Video getVideo(String type) {
//        if ("java".equalsIgnoreCase(type)) {
//            return new JavaVideo();
//        } else if ("python".equalsIgnoreCase(type)) {
//            return new PythonVideo();
//        } else if ("fe".equalsIgnoreCase(type)) {
//            return new FEVideo();
//        } else {
//            return null;
//        }
//    }
    public Video getVideo(Class c) {
        Video video = null;
        try {
            video = (Video) Class.forName(c.getName()).newInstance();
        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        return video;

    }
}
